﻿using System;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.BarterSystem.Barterables
{
	// Token: 0x02000415 RID: 1045
	public class GoldBarterable : Barterable
	{
		// Token: 0x17000D24 RID: 3364
		// (get) Token: 0x06003F8A RID: 16266 RVA: 0x00139E1B File Offset: 0x0013801B
		public override string StringID
		{
			get
			{
				return "gold_barterable";
			}
		}

		// Token: 0x17000D25 RID: 3365
		// (get) Token: 0x06003F8B RID: 16267 RVA: 0x00139E22 File Offset: 0x00138022
		public override int MaxAmount
		{
			get
			{
				return this._maxGold;
			}
		}

		// Token: 0x17000D26 RID: 3366
		// (get) Token: 0x06003F8C RID: 16268 RVA: 0x00139E2A File Offset: 0x0013802A
		public override TextObject Name
		{
			get
			{
				return GameTexts.FindText("str_char_denar_tooltip", null);
			}
		}

		// Token: 0x06003F8D RID: 16269 RVA: 0x00139E37 File Offset: 0x00138037
		public GoldBarterable(Hero owner, Hero other, PartyBase ownerParty, PartyBase otherParty, int val) : base(owner, ownerParty)
		{
			this._ownerHero = owner;
			this._otherHero = other;
			this._otherParty = otherParty;
			this._maxGold = val;
			base.CurrentAmount = 0;
		}

		// Token: 0x06003F8E RID: 16270 RVA: 0x00139E68 File Offset: 0x00138068
		public override int GetUnitValueForFaction(IFaction faction)
		{
			Hero originalOwner = base.OriginalOwner;
			if (faction != ((originalOwner != null) ? originalOwner.Clan : null))
			{
				Hero originalOwner2 = base.OriginalOwner;
				if (faction != ((originalOwner2 != null) ? originalOwner2.MapFaction : null))
				{
					PartyBase originalParty = base.OriginalParty;
					if (faction != ((originalParty != null) ? originalParty.MapFaction : null))
					{
						Hero otherHero = this._otherHero;
						if (faction != ((otherHero != null) ? otherHero.Clan : null))
						{
							Hero otherHero2 = this._otherHero;
							if (faction != ((otherHero2 != null) ? otherHero2.MapFaction : null))
							{
								PartyBase otherParty = this._otherParty;
								if (faction != ((otherParty != null) ? otherParty.MapFaction : null))
								{
									return 0;
								}
							}
						}
						return 1;
					}
				}
			}
			return -1;
		}

		// Token: 0x06003F8F RID: 16271 RVA: 0x00139EF8 File Offset: 0x001380F8
		public override ImageIdentifier GetVisualIdentifier()
		{
			return null;
		}

		// Token: 0x06003F90 RID: 16272 RVA: 0x00139EFB File Offset: 0x001380FB
		public override string GetEncyclopediaLink()
		{
			return "";
		}

		// Token: 0x06003F91 RID: 16273 RVA: 0x00139F04 File Offset: 0x00138104
		public override void Apply()
		{
			if (this._ownerHero != null && this._otherHero != null)
			{
				GiveGoldAction.ApplyBetweenCharacters(this._ownerHero, this._otherHero, base.CurrentAmount, false);
				return;
			}
			if (base.OriginalParty == PartyBase.MainParty)
			{
				GiveGoldAction.ApplyForCharacterToParty(Hero.MainHero, this._otherParty, base.CurrentAmount, false);
				return;
			}
			if (this._otherParty != PartyBase.MainParty)
			{
				GiveGoldAction.ApplyForPartyToParty(base.OriginalParty, this._otherParty, base.CurrentAmount, false);
				return;
			}
			GiveGoldAction.ApplyForPartyToCharacter(base.OriginalParty, Hero.MainHero, base.CurrentAmount, false);
		}

		// Token: 0x06003F92 RID: 16274 RVA: 0x00139F9C File Offset: 0x0013819C
		internal static void AutoGeneratedStaticCollectObjectsGoldBarterable(object o, List<object> collectedObjects)
		{
			((GoldBarterable)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
		}

		// Token: 0x06003F93 RID: 16275 RVA: 0x00139FAA File Offset: 0x001381AA
		protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
		{
			base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			collectedObjects.Add(this._ownerHero);
			collectedObjects.Add(this._otherHero);
			collectedObjects.Add(this._otherParty);
		}

		// Token: 0x06003F94 RID: 16276 RVA: 0x00139FD7 File Offset: 0x001381D7
		internal static object AutoGeneratedGetMemberValue_maxGold(object o)
		{
			return ((GoldBarterable)o)._maxGold;
		}

		// Token: 0x06003F95 RID: 16277 RVA: 0x00139FE9 File Offset: 0x001381E9
		internal static object AutoGeneratedGetMemberValue_ownerHero(object o)
		{
			return ((GoldBarterable)o)._ownerHero;
		}

		// Token: 0x06003F96 RID: 16278 RVA: 0x00139FF6 File Offset: 0x001381F6
		internal static object AutoGeneratedGetMemberValue_otherHero(object o)
		{
			return ((GoldBarterable)o)._otherHero;
		}

		// Token: 0x06003F97 RID: 16279 RVA: 0x0013A003 File Offset: 0x00138203
		internal static object AutoGeneratedGetMemberValue_otherParty(object o)
		{
			return ((GoldBarterable)o)._otherParty;
		}

		// Token: 0x04001294 RID: 4756
		[SaveableField(200)]
		private readonly int _maxGold;

		// Token: 0x04001295 RID: 4757
		[SaveableField(201)]
		private readonly Hero _ownerHero;

		// Token: 0x04001296 RID: 4758
		[SaveableField(202)]
		private readonly Hero _otherHero;

		// Token: 0x04001297 RID: 4759
		[SaveableField(203)]
		private readonly PartyBase _otherParty;
	}
}
